//
//  YJRegistVC.m
//  YJB
//
//  Created by 中电大维 on 16/5/12.
//  Copyright © 2016年 YJB. All rights reserved.
//

#import "YJRegistVC.h"
#import "YJRegistView.h"
#import "YJLoginVC.h"
@interface YJRegistVC ()
@property(nonatomic,weak)YJRegistView *registView;
@end

@implementation YJRegistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.tableView.scrollEnabled = NO;
    [self setupNav];
    //头部视图作为整个注册界面
    YJRegistView *registView = [[YJRegistView alloc]init];
    registView.telStr = self.telStr;
    registView.frame = CGRectMake(0, 0, IPHONE_W, IPHONE_H - 64);
    registView.backgroundColor = [UIColor whiteColor];
    _registView = registView;
    self.tableView.tableHeaderView = registView;
    self.tableView.tableFooterView = [UIView new];
    [NOTIFICATIONCENTER addObserver:self selector:@selector(keyedBoardShow) name:UIKeyboardWillShowNotification object:nil];
    [NOTIFICATIONCENTER addObserver:self selector:@selector(keyedBoardHidden) name:UIKeyboardWillHideNotification object:nil];
    [NOTIFICATIONCENTER addObserver:self selector:@selector(registSuccess) name:YJUserDidSuccessRegistNotification object:nil];
}


- (void)setupNav
{
    self.navigationItem.title = @"注册";
    self.automaticallyAdjustsScrollViewInsets = NO;
    //设置透明
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.tintColor = kUIColorFromRGB(0x333333);
    self.navigationController.navigationBar.barTintColor = NAVBACKGROUNDCOLOR;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:kUIColorFromRGB(0x333333),NSFontAttributeName:[UIFont systemFontOfSize:18.0f]}];
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(backItemClick) image:@"back_black" highImage:nil title:nil];
}

- (void)backItemClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)registSuccess
{
    [self.view endEditing:YES];
    [self.navigationController popToRootViewControllerAnimated:YES];

}
- (void)keyedBoardShow
{
    self.tableView.scrollEnabled = YES;
}

- (void)keyedBoardHidden
{
    self.tableView.scrollEnabled = NO;
}

-(void)dealloc
{
    [NOTIFICATIONCENTER removeObserver:self];
}
@end
